<?php
echo '<script type="text/javascript">';
require APP . WEBROOT_DIR . DS . "js" . DS . "validate" . DS . "expense_add.js";
echo '</script>';
?>
<div class="expenses form">
    <?php echo $this->Form->create('Expense'); ?>
    <fieldset>
        <legend><?php __('Agregar Gasto Extra'); ?></legend>
        <?php
        echo $this->Form->input('expensetype_id', array('label' => 'Tipo de Gasto'));
        echo $this->Form->input('employee_id', array('label' => 'Empleado'));
        echo $this->Form->input('value', array('label' => 'Monto'));
        echo $this->Form->input('date', array('type' => 'text', 'label' => 'Fecha'));
        echo $this->Form->input('description', array('label' => 'Descripción'));
        echo $this->Form->input('con_caja', array('type' => 'hidden', 'value' => 0));
        ?>
    </fieldset>
    <?php
    if ($header_tipo_usuario == GROUP_ADMIN) {
        echo $this->Form->submit(__('Crear', true), array('onclick' => 'return setear_caja(0);'));
    }
    echo $this->Form->submit(__('Crear Con Caja', true), array('onclick' => 'return setear_caja(1);'));
    echo $this->Form->end();
    ?>
</div>
<script type="text/javascript" defer>
    (function($){
        // Date picker
        $("#ExpenseDate").datepicker({
            //yearRange: '1970:2010',
            defaultDate: new Date(),
            dateFormat: 'dd/mm/yy',
            changeMonth: true,
            changeYear: true
        });
        
    })(jQuery);
    
    function setear_caja(valor){
        $('#ExpenseConCaja').val(valor);
        return true;
    }
</script>